package com.tianlan.blog.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import io.swagger.annotations.ApiModel;

@Entity
@Table(name ="sys_organization_user")
@ApiModel(value="OrganizationUser对象", description="")
@EntityListeners(AuditingEntityListener.class)
@DynamicUpdate
@DynamicInsert
@SQLDelete(sql = "update sys_organization_user set del_flag = 1 where id = ?")
@Where(clause = "del_flag = 0")
public class SysOrganizationUser {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(name = "organization_id")
    private Integer organizationId;

    @Column(name = "user_id")
    private Integer userId;

    @Column(name = "create_time")
    @CreatedDate
    private Date createTime;
    
    @Column(name = "creator")
    @CreatedBy
    private Integer creator;

    @Column(name = "update_time")
    @LastModifiedDate
    private Date updateTime;

    @Column(name = "operator")
    @LastModifiedBy
    private Integer operator;

    @Column(name = "del_flag")
    private String delFlag;

//    @ManyToOne(cascade = CascadeType.REFRESH, optional = false) 
//    @JoinColumn(name = "user_id",insertable=false,updatable=false)
//    private SysUser sysUser;
    
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }
    public Integer getOrganizationId() {
        return organizationId;
    }

    public void setOrganizationId(Integer organizationId) {
        this.organizationId = organizationId;
    }
    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Integer getCreator() {
        return creator;
    }

    public void setCreator(Integer creator) {
        this.creator = creator;
    }
    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Integer getOperator() {
        return operator;
    }

    public void setOperator(Integer operator) {
        this.operator = operator;
    }
    public String getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    @Override
    public String toString() {
        return "OrganizationUser{" +
        "id=" + id +
        ", organizationId=" + organizationId +
        ", userId=" + userId +
        ", createTime=" + createTime +
        ", creator=" + creator +
        ", updateTime=" + updateTime +
        ", operator=" + operator +
        ", delFlag=" + delFlag +
        "}";
    }
}
